package com.bank.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.bank.utils.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @author 王迎澳
 * @version 1.0
 * @school hhu
 * @date 2022/6/22 12:01
 */
@Configuration
@PropertySource("classpath:connect.properties")
public class AllConfig {

    @Value("${druid.url}")
    String url;

    @Value("${druid.driverClassName}")
    String driverClassName;

    @Value("${druid.username}")
    String username;

    @Value("${druid.password}")
    String password;

    @Bean
    public DruidDataSource dataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        dataSource.setDriverClassName(driverClassName);
        dataSource.setMaxActive(20);
        dataSource.setMaxWait(60000);
        dataSource.setMinIdle(5);
        dataSource.setInitialSize(5);
        return dataSource;
    }
}
